#pragma once

/*---------------------------------------------------------------------------*/
/*                                Image Data                                 */
/*---------------------------------------------------------------------------*/

#define IMG_DIGIT_W 8
#define IMG_DIGIT_H 14

PROGMEM static const uint8_t imgDigit[][16] = { // 8x14 x10
    { 0xFC, 0xFE, 0x03, 0x01, 0x03, 0xFE, 0xFC, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 },
    { 0x00, 0x02, 0x02, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00 },
    { 0x0C, 0x0E, 0x03, 0x81, 0xE3, 0x7E, 0x1C, 0x00, 0x18, 0x1C, 0x17, 0x13, 0x10, 0x10, 0x10, 0x00 },
    { 0x0C, 0x0E, 0x43, 0x41, 0xE3, 0xBE, 0x1C, 0x00, 0x06, 0x0E, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 },
    { 0x00, 0xC0, 0xF0, 0x3C, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0x03, 0x02, 0x02, 0x1F, 0x1F, 0x02, 0x00 },
    { 0x7F, 0x7F, 0x31, 0x11, 0x31, 0xE1, 0xC1, 0x00, 0x04, 0x0C, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 },
    { 0xFC, 0xFE, 0x63, 0x21, 0x63, 0xCE, 0x8C, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 },
    { 0x01, 0x01, 0x01, 0xC1, 0xF9, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00, 0x00 },
    { 0x1C, 0xBE, 0xE3, 0x41, 0xE3, 0xBE, 0x1C, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 },
    { 0x3C, 0x7E, 0xC3, 0x81, 0xC3, 0xFE, 0xFC, 0x00, 0x06, 0x0E, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00 }
};

#define IMG_BIGDIGIT_W 16
#define IMG_BIGDIGIT_H 24

PROGMEM static const uint8_t imgBigDigit[][48] = { // 16x24 x11
    {
        0x00, 0xE0, 0xF8, 0xFC, 0x7E, 0x0E, 0x07, 0x07, 0x07, 0x0E, 0x7E, 0xFC, 0xF8, 0xE0, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
        0x00, 0x07, 0x1F, 0x3F, 0x7E, 0xF0, 0xE0, 0xE0, 0xE0, 0xF0, 0x7E, 0x3F, 0x1F, 0x07, 0x00, 0x00
    },{
        0x00, 0x00, 0x30, 0x30, 0x30, 0x38, 0xFC, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    },{
        0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0x0E, 0x07, 0x07, 0x07, 0x0E, 0xFE, 0xFE, 0xFC, 0xF0, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xFC, 0x7F, 0x1F, 0x0F, 0x07, 0x00, 0x00, 0x00,
        0xC0, 0xF0, 0xFC, 0xFE, 0xFF, 0xEF, 0xE3, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00
    },{
        0x00, 0x70, 0x7C, 0x7E, 0x7E, 0x0F, 0x07, 0x07, 0x07, 0x0E, 0xFE, 0xFC, 0xF8, 0xE0, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C, 0x7E, 0xFF, 0xE7, 0xC3, 0x80, 0x00, 0x00,
        0x03, 0x1F, 0x3F, 0x7F, 0xF8, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xFF, 0x7F, 0x3F, 0x0F, 0x00, 0x00
    },{
        0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
        0x80, 0xE0, 0xF8, 0xFE, 0x3F, 0x0F, 0x03, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
        0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x00
    },{
        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00,
        0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x0C, 0x0E, 0x06, 0x06, 0x1E, 0xFE, 0xFC, 0xF8, 0xE0, 0x00, 0x00,
        0x02, 0x1E, 0x3E, 0x7E, 0xF8, 0xE0, 0xE0, 0xE0, 0xE0, 0xF8, 0x7F, 0x3F, 0x1F, 0x07, 0x00, 0x00
    },{
        0x00, 0x80, 0xF0, 0xF8, 0xFC, 0x7E, 0x0F, 0x07, 0x07, 0x0F, 0x3E, 0x3E, 0x3C, 0x30, 0x00, 0x00,
        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0x0E, 0x06, 0x06, 0x0E, 0xFE, 0xFC, 0xF8, 0xF0, 0x00, 0x00,
        0x00, 0x03, 0x1F, 0x3F, 0x7F, 0xF8, 0xF0, 0xE0, 0xE0, 0xF0, 0xFF, 0x7F, 0x3F, 0x0F, 0x00, 0x00
    },{
        0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xC7, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    },{
        0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0x0E, 0x07, 0x07, 0x07, 0x0E, 0xFE, 0xFC, 0xF8, 0xE0, 0x00, 0x00,
        0x00, 0xC0, 0xE3, 0xF7, 0x7F, 0x3E, 0x1C, 0x1C, 0x1C, 0x3E, 0x7F, 0xF7, 0xE3, 0xC0, 0x00, 0x00,
        0x07, 0x1F, 0x3F, 0x7F, 0xF8, 0xF0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF8, 0x7F, 0x3F, 0x1F, 0x07, 0x00
    },{
        0x00, 0xF0, 0xFC, 0xFE, 0xFE, 0x0F, 0x07, 0x07, 0x0F, 0x1E, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00,
        0x00, 0x0F, 0x3F, 0x7F, 0x7F, 0xF0, 0xE0, 0xE0, 0x70, 0x78, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
        0x00, 0x1C, 0x3C, 0x7C, 0xFC, 0xF0, 0xE0, 0xE0, 0xF0, 0xFC, 0x7F, 0x3F, 0x0F, 0x03, 0x00, 0x00
    },{
        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x78, 0xFE, 0xFF, 0xCF, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00,
        0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x01, 0x07, 0x1F, 0xFF, 0xFC, 0xF0, 0xC0, 0x00, 0x00
    }
};

#define IMG_PI_W 24
#define IMG_PI_H 24

PROGMEM static const uint8_t imgPi[72] = { // 24x24
    0x00, 0x04, 0x1C, 0x1C, 0x1C, 0x0E, 0x0E, 0x0E, 0xFE, 0xFE, 0xFE, 0x7E, 0x0E, 0x0E, 0x0E, 0xFE,
    0xFC, 0xFC, 0xFC, 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFF,
    0xFF, 0x7F, 0x07, 0x00, 0x00, 0x80, 0xFE, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x20, 0x70, 0xF8, 0xFC, 0x7F, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x3F, 0x3F,
    0x7F, 0x78, 0x70, 0x70, 0x70, 0x30, 0x00, 0x00
};

#define IMG_DOTS_W 8
#define IMG_DOTS_H 8

PROGMEM static const uint8_t imgDots[8] = { // 8x8
    0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0xC0, 0xC0
};

#define IMG_ICON_W 7
#define IMG_ICON_H 7

enum {
    IMG_ICON_ID_UP = 0,
    IMG_ICON_ID_DOWN,
    IMG_ICON_ID_LEFTRIGHT,
    IMG_ICON_ID_A,
    IMG_ICON_ID_B,
    IMG_ICON_ID_MAX
};

PROGMEM static const uint8_t imgIcon[][7] = { // 7x7 x5
    { 0x00, 0x20, 0x38, 0x3E, 0x38, 0x20, 0x00 },
    { 0x00, 0x02, 0x0E, 0x3E, 0x0E, 0x02, 0x00 },
    { 0x08, 0x1C, 0x3E, 0x00, 0x3E, 0x1C, 0x08 },
    { 0x3E, 0x47, 0x6B, 0x6D, 0x6D, 0x41, 0x3E },
    { 0x3E, 0x41, 0x55, 0x55, 0x51, 0x65, 0x3E }
};

#define IMG_CHOICE_W 13
#define IMG_CHOICE_H 8

enum {
    IMG_CHOICE_ID_LED_OFF = 0,
    IMG_CHOICE_ID_LED_ON,
    IMG_CHOICE_ID_SOUND_OFF,
    IMG_CHOICE_ID_SOUND_ON,
    IMG_CHOICE_ID_PERSEC,
    IMG_CHOICE_ID_STOP,
    IMG_CHOICE_ID_PLAY,
    IMG_CHOICE_ID_MAX
};

PROGMEM static const uint8_t imgChoice[][13] = { // 13x8 x6
    { 0x00, 0x00, 0x1C, 0x1C, 0x14, 0x14, 0x14, 0x14, 0x14, 0x1C, 0x1C, 0x00, 0x00 },
    { 0x2A, 0x00, 0x5D, 0x1C, 0x55, 0x14, 0x55, 0x14, 0x55, 0x1C, 0x5D, 0x00, 0x2A },
    { 0x1C, 0x1C, 0x00, 0x1C, 0x3E, 0x7F, 0x00, 0x00, 0x14, 0x08, 0x14, 0x00, 0x00 },
    { 0x1C, 0x1C, 0x00, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x08, 0x22, 0x1C, 0x41, 0x3E },
    { 0x20, 0x10, 0xA8, 0xB4, 0x52, 0x00, 0xF0, 0xB0, 0x90, 0x00, 0xE0, 0x90, 0x90 },
    { 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00 },
    { 0x00, 0x00, 0x7F, 0x3E, 0x3E, 0x3E, 0x1C, 0x1C, 0x1C, 0x08, 0x08, 0x00, 0x00 }
};

/*---------------------------------------------------------------------------*/
/*                                Sound Data                                 */
/*---------------------------------------------------------------------------*/

PROGMEM static const uint8_t soundDigit[][14] = {
    { 0x90, 0x38, 0x00, 0x0A, 0x90, 0x44, 0x00, 0x28, 0x90, 0x50, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x39, 0x00, 0x0A, 0x90, 0x45, 0x00, 0x28, 0x90, 0x51, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x3B, 0x00, 0x0A, 0x90, 0x47, 0x00, 0x28, 0x90, 0x53, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x3C, 0x00, 0x0A, 0x90, 0x48, 0x00, 0x28, 0x90, 0x54, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x3E, 0x00, 0x0A, 0x90, 0x4A, 0x00, 0x28, 0x90, 0x56, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x40, 0x00, 0x0A, 0x90, 0x4C, 0x00, 0x28, 0x90, 0x58, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x41, 0x00, 0x0A, 0x90, 0x4D, 0x00, 0x28, 0x90, 0x59, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x44, 0x00, 0x0A, 0x90, 0x50, 0x00, 0x28, 0x90, 0x5C, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x45, 0x00, 0x0A, 0x90, 0x51, 0x00, 0x28, 0x90, 0x5D, 0x00, 0x14, 0x80, 0xF0 },
    { 0x90, 0x47, 0x00, 0x0A, 0x90, 0x53, 0x00, 0x28, 0x90, 0x5F, 0x00, 0x14, 0x80, 0xF0 }
};

/*---------------------------------------------------------------------------*/
/*                                Other Data                                 */
/*---------------------------------------------------------------------------*/

#define LED_VALUE(r, g, b)  ((r) * 25 + (g) * 5 + (b))
#define LED_LEVEL_START     16

PROGMEM static const uint8_t ledValues[] = {
    LED_VALUE(2, 2, 2), LED_VALUE(4, 0, 0), LED_VALUE(0, 0, 4), LED_VALUE(3, 3, 0), LED_VALUE(0, 3, 0),
    LED_VALUE(4, 1, 2), LED_VALUE(2, 1, 0), LED_VALUE(2, 0, 3), LED_VALUE(2, 4, 0), LED_VALUE(0, 3, 3)
};

#define PLAY_SPEED_MAX      sizeof(playSpeedTable)
#define getWaitInterval(s)  pgm_read_byte(playSpeedTable + s)

PROGMEM static const uint8_t playSpeedTable[] = {
    60, 30, 20, 15, 12, 10, 8, 7, 6, 5, 4, 3, 2, 1
};
